#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

int getLongest(int num[], int size)
{
    map<int, bool> mp;
    int longest = 0;
    for (int i = 0; i < size; i++) {
	cout << num[i] << " ";
	mp[num[i]] = false;
    }
    cout << endl;

    for (int i = 0; i < size; i++) {
        if (!mp[num[i]]) {
	    int count = 1;  
	    mp[num[i]] = true;
	    int left = num[i]-1;
	    while(mp.count(left) && !mp[left]) {
		cout << left << " "<< count << endl;
	        mp[left] = true;
		count++;
		left--;
	    }
	    int right = num[i]+1;
	    while(mp.count(right) && !mp[right]) {
		mp[right] = true;
		count++;
		right++;
	    }
	    longest = max(count, longest);	
	}
    }
    cout << longest << endl;
    return longest;
}


int main(int argc, char **argv)
{
    int A[] = {4,100,102,5,2,4,0,45,64,3,4,56,67};
    cout << getLongest(A, sizeof(A)/sizeof(int));

}
